<!DOCTYPE html>
<html>
<head>
    <!--hospital_purchase_catalog-->
	<meta charset="utf-8">
	<title>文章列表--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<!--模糊查询-->
<div>
    <blockquote style="margin-right: 10%" class="layui-elem-quote quoteBox layui-col-lg-offset1">
        <form class="layui-form" id="searchTable" lay-filter="searchTable">
            <div class="layui-form-item layui-row">
    	        <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购单编号</label>
                	<div class="layui-input-block">
                		<input type="text" name="purchaseNum" class="layui-input searchVal" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购单名称</label>
                	<div class="layui-input-block">
                		<input type="text" name="purchaseName" class="layui-input searchVal" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
    	        <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购状态</label>
                	<div class="layui-input-block">
                		<select name="purchaseState" id="moPurchaseState" lay-filter="quality">
                            <option>请选择采购状态：</option>
                        </select>
                        <div class="mydiv" title="不可修改" style="position:absolute;width: 100%;height: 100%;left: 0px;top: 0px;background: #fff;opacity: 0;filter:alpha(opacity=0)"></div>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购医院</label>
                	<div class="layui-input-block">
                		<input type="text" name="hospitalName" class="layui-input searchVal" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">开始采购时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="createTime" autocomplete="off" id="startPT" class="layui-input searchVal" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">结束采购时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="overTime" autocomplete="off" id="endPT" class="layui-input searchVal" />
                	</div>
                </div>
            </div>
    	    <div class="layui-form-item layui-row">
    	        <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">药品流水号</label>
                	<div class="layui-input-block">
                		<input type="text" name="serialNumber" id="serialNumber" class="layui-input searchVal" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">通用名</label>
                	<div class="layui-input-block">
                		<input type="text" name="commonName" id="commonName" class="layui-input searchVal" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">剂型</label>
                	<div class="layui-input-block">
                	    <input name="dosageForm" class="layui-input searchVal" id="dosageForm" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">规格</label>
                	<div class="layui-input-block">
                	    <input name="size" class="layui-input searchVal" id="size" >
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">单位</label>
                	<div class="layui-input-block">
                		<input type="text" name="unit" class="layui-input createTime">
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                	<label class="layui-form-label">转换系数</label>
                	<div class="layui-input-block">
                    	<input type="text" class="layui-input" name="factor" id="factor">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">生产企业</label>
                	<div class="layui-input-block">
                		<input type="text" name="productionName" class="layui-input searchVal"/>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">商品名</label>
                	<div class="layui-input-block">
                		<input type="text" name="commodityName" class="layui-input searchVal"/>
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">质量层次</label>
                	<div class="layui-input-block">
                		<select name="quality" id="moQuality" lay-filter="quality">
                            <option>请选择质量层次：</option>
                        </select>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">药品类别</label>
                	<div class="layui-input-block">
                		<select name="drugCategory" id="moDrugCategory">
                            <option>请选择药品类别：</option>
                        </select>
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">药品批号</label>
                	<div class="layui-input-block">
                        <input type="text" class="layui-input" name="approvalNumber">
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">入库时间</label>
                    <div class="layui-input-inline">
                    	<input type="text" class="layui-input" name="startTime" id="startCreateTime" autocomplete="off" placeholder="yyyy-MM-dd">
                    </div>
                    <label class="layui-form-label" style="width: 5px">-</label>
                    <div class="layui-input-inline">
                    	<input type="text" class="layui-input" name="endTime" id="endCreateTime" autocomplete="off" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-form-item layui-row">
                    <div class="layui-inline layui-col-md5">
                        <label class="layui-form-label">发票号/入库单号</label>
                    	<div class="layui-input-block">
                    		<input type="text" name="inputForm" class="layui-input searchVal" />
                    	</div>
                    </div>
                    <div class="layui-inline layui-col-md5">
                        <label class="layui-form-label">供应商</label>
                    	<div class="layui-input-block">
                    		<select name="providerId" id="moProvider" lay-filter="provider">
                                <option>请选择供应商：</option>
                            </select>
                    	</div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-center">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="search">查询</button>
                   <button type="button" class="layui-btn" lay-submit="" lay-filter="close">关闭</button>
                </div>
            </div>
    	</form>
    </blockquote>
</div>
<!--查看-->
<div style="display: none" id="showData" lay-filter="showData">
	<h2 style="margin-left: 10px">药品信息</h2>
	<form class="layui-form" id="showDataDrugForm" lay-filter="showDataDrugForm">
        <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">药品名</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="commodityName" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">药品流水号</label>
            	<div class="layui-input-inline">
            		<input type="text" name="serialNumber" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">药品通用名</label>
            	<div class="layui-input-inline">
            	    <input name="commonName" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">批准文号</label>
            	<div class="layui-input-inline">
            		<input type="text" name="approvalNumber" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">剂型</label>
            	<div class="layui-input-inline">
            		<input type="text" name="dosageForm" class="layui-input" readonly>
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">规格</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="size" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">单位</label>
            	<div class="layui-input-inline">
            		<input type="text" name="unit" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">转换系数</label>
            	<div class="layui-input-inline">
            		<input type="text" name="factor" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="quality" id="layerQuality" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">生产企业</label>
            	<div class="layui-input-inline">
            		<input type="text" name="productionName" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">药品类别</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="drugCategory" id="layerDrugCategory" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">通用名拼音</label>
            	<div class="layui-input-inline">
            		<input type="text" name="commodityPinyin" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">批准文号有效期</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="approvalDate" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">是否是进口药</label>
            	<div class="layui-input-inline">
            		<input type="text" name="isImport" id="layerIsImport" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">包装材质</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="packages" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">包装单位</label>
            	<div class="layui-input-inline">
            		<input type="text" name="packageUnit" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">最新零售价</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="newPrice" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">零售价出处</label>
            	<div class="layui-input-inline">
            		<input type="text" name="priceSource" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="qualityDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">有无质检报告</label>
            	<div class="layui-input-inline">
            		<input type="text" name="haveReport" id="layerHaveReport" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质检报告编号</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="reportNum" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">质检报告有效期</label>
            	<div class="layui-input-inline">
            		<input type="text" name="reportDate" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">产品说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="productionDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">药品状态</label>
            	<div class="layui-input-inline">
            		<input type="text" name="transaction" id="layerTransaction" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="qualityDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
    </form>
    <h2 style="margin-left: 10px">采购单详情</h2>
    <form class="layui-form" id="showPurchase" lay-filter="showPurchase">
	    <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">医院编号</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="hospitalId" id="hospitalId" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">医院名称</label>
            	<div class="layui-input-inline">
            		<input type="text" name="hospitalName" id="layerHospitalName" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购单编号</label>
            	<div class="layui-input-inline">
            	    <input name="purchaseNum" class="layui-input searchVal" id="purchaseNum" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">采购单名称</label>
            	<div class="layui-input-inline" style="width: 300px;">
            	    <input name="purchaseName" readonly class="layui-input searchVal" lay-verify="required" id="purchaseName" placeholder="请输入采购单名称" >
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="createTime" class="layui-input createTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">结束时间</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="overTime" lay-verify="required" readonly id="overTime" placeholder="yyyy-MM-dd">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">联系人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="linkman" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">联系电话</label>
            	<div class="layui-input-inline">
            		<input type="text" name="linkphone" lay-verify="required|phone" class="layui-input searchVal" placeholder="请输入联系电话" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">采购单状态</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="purchaseState" id="layerPurchaseState" class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">提交时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="submitTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-block ">
                <label class="layui-form-label">备注</label>
            	<div class="layui-input-block" style="width: 515px">
            		<input type="text" name="remark" class="layui-input searchVal" placeholder="请输入备注" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">审核人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditor" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">审核时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditorTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">建单时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="createTime" readonly class="layui-input searchVal createTime" placeholder="yyyy-MM-dd"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">审核意见</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditorAdvice" readonly class="layui-input searchVal" placeholder="请输入审核意见" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购数量</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchaseAmount" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">采购价格</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchasePrice" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购状态</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchaseState"  readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">交易价</label>
            	<div class="layui-input-inline">
            		<input type="text" name="trading" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">中标价</label>
            	<div class="layui-input-inline">
            		<input type="text" name="winPrice" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
	</form>
    <h2 style="margin-left: 10px">入库单详情</h2>
    <form class="layui-form" id="showInput" lay-filter="showInput">
	    <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">入库数量</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="inputNum" id="inputNum" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">入库金额</label>
            	<div class="layui-input-inline">
            		<input type="text" name="inputPrice" id="inputPrice" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">发票号</label>
            	<div class="layui-input-inline">
            	    <input name="invoiceNum" class="layui-input searchVal" id="invoiceNum" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">入库单号</label>
            	<div class="layui-input-inline" style="width: 300px;">
            	    <input name="inputForm" readonly class="layui-input searchVal" lay-verify="required" id="inputForm" placeholder="请输入采购单名称" >
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">药品批号</label>
            	<div class="layui-input-inline">
            		<input type="text" name="batchNumber" class="layui-input createTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">药品有效期</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="drugTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">入库时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="inputTime" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
        </div>
	</form>
    <h2 style="margin-left: 10px">退货单详情</h2>
    <form class="layui-form" id="showOutput" lay-filter="showOutput">
	    <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">退货单编号</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="outputNum" id="outputNum" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">退货单名称</label>
            	<div class="layui-input-inline">
            		<input type="text" name="outputName" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">联系人</label>
            	<div class="layui-input-inline">
            	    <input name="linkman" class="layui-input searchVal" id="linkman" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">联系电话</label>
            	<div class="layui-input-inline" style="width: 300px;">
            	    <input name="linkphone" readonly class="layui-input searchVal" lay-verify="required" id="linkphone" placeholder="请输入采购单名称" >
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">建单人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="createName" class="layui-input" lay-verify="required" readonly placeholder="yyyy-MM-dd">
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">建单时间</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="createTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">提交时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="submitTime" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">备注</label>
            	<div class="layui-input-inline">
            		<input type="text" name="remark" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">退货单状态</label>
            	<div class="layui-input-inline">
            		<input type="text" name="outputState" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
        </div>
	</form>

</div>
<!--数据表格-->
<div>
    <table class="layui-hide" id="closeTable" lay-filter="closeTable"></table>
    <div id="toolBars" style="display: none">
        <button type="button" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>添加</button>
    </div>
    <div id="rowBars" style="display: none">
        <button type="button" lay-event="show" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>查看</button>
    </div>
</div>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer','laydate','element','table','slider'],function() {
        var form = layui.form;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var $ = layui.jquery;
        var table = layui.table;
        var slider = layui.slider;
        //滑块渲染
        var sliderIns = slider.render({
            elem: '#priceRange'
            ,min:0
            ,max:1000
            ,value: [0, 1000] //初始值
            ,range: true //范围选择
            ,change: function(vals){
                $('input[name="minPrice"]').val(vals[0]);
                $('input[name="maxPrice"]').val(vals[1]);
            }
        });
        //时间渲染
        laydate.render({
            elem:"#startPT",
            type:'date'
        })
        laydate.render({
            elem:"#endPT",
            type:'date'
        })
        laydate.render({
            elem:"#startCreateTime",
            type:'datetime'
        })
        laydate.render({
            elem:"#endCreateTime",
            type:'datetime'
        })
        //获取传过来的供应商id
        var id = window.location.href.split("id=")[1];
        if(id.indexOf("&")!=-1){
            id = id.split("&")[0];
        }
        //传过来的药品信息Id，用来筛选已经添加过的采购详情
        var drugMessageIds = window.location.href.split("drugMessageIds=")[1];
        if(drugMessageIds.indexOf("&")!=-1){
            drugMessageIds = drugMessageIds.split("&")[0];
        }
        //传过来的采购单id，用来筛选已经添加过的采购详情
        var purchaseIds = window.location.href.split("purchaseIds=")[1];
        if(purchaseIds.indexOf("&")!=-1){
            purchaseIds = purchaseIds.split("&")[0];
        }
        //获取医院Id
        var hospitalId = window.location.href.split("hospitalId=")[1];
        if(hospitalId.indexOf("&")!=-1){
            hospitalId = hospitalId.split("&")[0];
        }
        //数据表格渲染
        var tableIns = table.render({
            elem:"#closeTable",
            url:"/hospitalClose/getAvaCatalog",
            where:{drugMessageIds:drugMessageIds,purchaseIds:purchaseIds,hospitalId:hospitalId},
            toolbar:"#toolBars",
            page:true,
            id:'closeTableId',
            height:'470',
            cols:[
                [
                    {field:'id', title:'ID',  fixed: 'left', unresize: true,width:'80' ,sort: true,align:'center', totalRowText: '合计'}
                    ,{type:'checkbox',fixed:'center'}
                    ,{field:'purchase.purchaseNum', title:'采购单编号',align:'center',width:'180',sort:true,templet:function(res) {
                        console.log(res);
                        return res.purchase==null?"":
                        res.purchase.purchaseNum==null?"":
                        res.purchase.purchaseNum;
                    }}
                    ,{field:'purchase.purchaseName', title:'采购单名称',align:'center',width:'180',templet:function(res) {
                        return res.purchase==null?"":
                        res.purchase.purchaseName==null?"":
                        res.purchase.purchaseName;
                    }}
                    ,{field:'drugMessage.serialNumber', title:'流水号',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.serialNumber;
                    }}
                    ,{field:'drugMessage.commonName', title:'通用名',align:'center',sort:true,width:'180',templet:function (res) {
                        return res.drugMessage==undefined?"":res.drugMessage.commonName;
                     }}
                    ,{field:'drugMessage.commodityName', title:'商品名',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.commodityName;
                    }}
                    ,{field:'winPrice', title:'中标价',align:'center',width:'180'}
                    ,{field:'trading', title:'交易价',align:'center',width:'180'}
                    ,{field:'purchaseAmount', title:'采购量',align:'center',width:'180',totalRow: true}
                    ,{field:'purchasePrice', title:'采购总金额',align:'center',width:'180',totalRow: true}
                    ,{field:'input.inputNum', title:'入库量',align:'center',width:'180',totalRow: true,templet:function(res) {
                        return res.input==null?"":
                        res.input.inputNum==null?"":
                        res.input.inputNum;
                    }}
                    ,{field:'input.inputPrice', title:'实际交易金额',align:'center',width:'180',totalRow: true,templet:function(res) {
                        return res.input==null?"":
                        res.input.inputPrice==null?"":
                        res.input.inputPrice;
                    }}
                    ,{field:'drugMessage.approvalNumber', title:'药品批号',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==null?"":
                        res.drugMessage.approvalNumber==null?"":
                        res.drugMessage.approvalNumber;
                    }}
                    ,{field:'drugMessage.approvalDate', title:'药品有效期',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==null?"":
                        res.drugMessage.approvalDate==null?"":
                        res.drugMessage.approvalDate;
                    }}
                    ,{field:'output.returnsTheAmount', title:'退货量',align:'center',width:'180',totalRow: true,templet:function(res) {
                        return res.output==null?"":
                        res.output.returnsTheAmount==null?"":
                        res.output.returnsTheAmount;
                    }}
                    ,{field:'output.returnsTheAmount', title:'退货金额',align:'center',width:'180',totalRow: true,templet:function(res) {
                        return res.output==null?"":
                        res.output.outputPrice==null?"":
                        res.output.outputPrice;
                    }}
                    ,{field:'drugMessage.dosageForm', title:'剂型',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.dosageForm;
                    }}
                    ,{field:'drugMessage.size', title:'规格',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.size;
                    }}
                    ,{field:'drugMessage.unit', title:'单位',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.unit;
                    }}
                    ,{field:'drugMessage.factor', title:'转换系数',align:'center',width:'180',templet:function (res) {
                        return res.drugMessage==undefined?"":res.drugMessage.factor;
                     }}
                    ,{field:'drugMessage.quality', title:'质量层次',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.quality==1?"国家一类新药":
                        res.drugMessage.quality==2?"国家科学进步奖":
                        res.drugMessage.quality==3?"专利":
                        res.drugMessage.quality==4?"原研":
                        res.drugMessage.quality==5?"单独定价":
                        res.drugMessage.quality==6?"优质优价":
                        res.drugMessage.quality==7?"GMP":"";
                    }}
                    ,{field:'drugMessage.productionName', title:'生产企业',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.productionName;
                    }}
                    ,{field:'provider.providerName', title:'供货企业',align:'center',width:'180',templet:function(res) {
                        return res.provider==undefined?"":res.provider.providerName
                    }}
                    ,{field:'purchase.createTime', title:'开始采购时间',align:'center',width:'180',templet:function(res) {
                        return res.purchase==null?"":
                        res.purchase.createTime==null?"":
                        res.purchase.createTime.substring(0,10);
                    }}
                    ,{field:'purchase.overTime', title:'结束采购时间',align:'center',width:'180',templet:function(res) {
                        return res.purchase==null?"":
                        res.purchase.overTime==null?"":
                        res.purchase.overTime.substring(0,10);
                    }}
                    ,{fixed: 'right', title:'操作', toolbar: '#rowBars',width:100}
                ]
            ]
        });
        //表单提交，查询
        form.on('submit(search)',function(data) {
            tableIns.reload({
                where:data.field
            })
            return false;
        });
        //关闭，返回到采购单维护
        form.on('submit(close)',function(data) {
            //获取结算单Id
            window.location.href = "toCloseMaintain?id="+id;
            return false;
        });
        //监听头部工具栏事件
        table.on('toolbar(closeTable)',function(obj) {
            switch (obj.event) {
                case 'add':
                    openAdd();
                    break;
            }
        });
        //监听行工具栏
        table.on('tool(closeTable)',function(obj){
            switch (obj.event) {
                case 'show':
                    openShow(obj.data);
            }
        });
        //加载药品
        selectDrugCategory($("#moDrugCategory"),"/getDrugCategory");
        //质量层次
        select($("#moQuality"),"/getDataDictionary?dateType=7");
        //采购状态
        select($("#moPurchaseState"),"/getDataDictionary?dateType=3",3);
        //供应商
        selectProvider($("#moProvider"),"/provider/getProvider");
        //药品供应商信息展示
        var mainIns;
        function openShow(data) {
            console.log(data);
            mainIns = layer.open({
                type:1,
                content:$("#showData"),
                area:['800px','630px'],
                title:"查看详情",
                success:function(layero,index) {
                    console.log(data);
                    form.val("showDataDrugForm",data.drugMessage);
                    //质量层次
                    $.post("/getDataDictionaryName",{dateType:7,dataNum:data.drugMessage.quality},function(res) {
                        $("#layerQuality").val(res);
                    });
                    //药品类别
                    $.post("/getDrugCategoryById",{drugCategoryId:data.drugMessage.drugCategory},function(res) {
                        $("#layerDrugCategory").val(res.category);
                    });
                    //是否进口药
                    $("#layerIsImport").val(data.drugMessage.isImport==1?"是":"否");
                    //有无质检报告
                    $("#layerHaveReport").val(data.drugMessage.haveReport==1?"是":"否");
                    //药品状态
                    $.post("/getDataDictionaryName",{dateType:1,dataNum:data.drugMessage.transaction},function(res) {
                        $("#layerTransaction").val(res);
                    });
                    form.val("showPurchase",data.purchase);
                    //采购医院
                    $.post("/hospital/getHospitalById",{id:data.purchase.hospitalId},function(res) {
                        $("#layerHospitalName").val(res.hospitalName);
                    });
                    //采购单状态
                    $.post("/getDataDictionaryName",{dateType:2,dataNum:data.purchase.purchaseState},function(res) {
                        $("#layerPurchaseState").val(res);
                    });
                    //采购详情
                    form.val("showPurchase",data);
                    form.val("showInput",data.input);
                    form.val("showOutput",data.output);
                }
            });
        }
        //添加结算药品，添加到hospital_close_detail
        function openAdd() {
            var checkStatus = table.checkStatus('closeTableId');
            //获取选中信息
            var closeId = id;
            var drugMessages = new Array();
            var purchases = new Array();
            if(checkStatus.data.length==0){
                layer.msg("请选择要添加的药品");
                return;
            }
            $.each(checkStatus.data,function(index,item) {
                drugMessages.push(item.drugMessageId);//药品信息Id
                purchases.push(item.purchaseId);
            });
            var formData = new FormData();
            formData.append("drugMessageIds",drugMessages);
            formData.append("purchaseIds",purchases);
            formData.append("closeId",closeId);
            $.ajax({
                url:"/addHospitalCloseDetail",
                data:formData,
                type:"post",
                dataType:"json",
                async:false,
                contentType:false,
                processData:false,
                success:function(data) {
                    layer.msg(data.msg);
                    if(data.code==200){
                        //延时
                        setTimeout(function() {
                            window.location.href = "toCloseMaintain?id="+id;
                        },1000);
                    }
                }
            })

        }
        //加载下拉框
        function select(item,url,dataNum) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择</option>";
                $.each(data.data,function(index,item) {
                    if(item.dataNum===dataNum){
                        html += "<option selected value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }else {
                        html += "<option value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
        function selectDrugCategory(item,url) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择药品类别</option>";
                $.each(data,function(index,item) {
                    html += "<option value='"+item.id+"'>"+item.category+"</option>"
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
        function selectProvider(item,url) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择供应商</option>";
                $.each(data,function(index,item) {
                    html += "<option value='"+item.id+"'>"+item.providerName+"</option>"
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
    })
</script>
</body>